const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    index:0,
    maxIndex:5,
    clientY:0,
    img: app.globalData.img,
    height: []
  },
  moveStart(e) {
    this.setData({
      pageY: e.changedTouches[0].clientY
    })
  },
  moveBlock(e) {
    console.log(this.data.height)
    if (((this.data.pageY - e.changedTouches[0].clientY) > 10) && this.data.index < this.data.maxIndex) {
      var index = this.data.index + 1
      var arr = this.data.height
      arr[this.data.index] = "1rpx"
      arr[index] = "800rpx"
      this.setData({
        height: arr,
        index: index
      })
    }
    if (((e.changedTouches[0].clientY - this.data.pageY) > 10) && this.data.index > 0) {
      var index = this.data.index - 1
      var arr = this.data.height
      arr[this.data.index] = "200rpx"
      arr[index] = "800rpx"
      this.setData({
        height: arr,
        index: index
      })
    }
  },
  scrollClick(e){
    var currentIndex = e.currentTarget.dataset.index
    var arr = this.data.height
    if (currentIndex > this.data.index){
      for (let i = 0; i < currentIndex; i++){
        arr[i] = "0"
      }
      arr[currentIndex] = "800rpx"
      this.setData({
        height: arr,
        index: currentIndex
      })
    } else if (currentIndex == this.data.index){
      wx.navigateTo({
        url: '/pages/example/example?id=' + currentIndex + '&name=' + e.currentTarget.dataset.title
      })
    }
  },
  case:function() {
    var that = this
    app.req({
      url: 'Info?isTop=true',
      success:function(res) {
        var arr = []
        for (let i = 0; i < res.data.Result.Items.length;i++){
          if(i==0){
            arr.push("800rpx")
          }else{
            arr.push("200rpx")
          }
          that.setData({
            height: arr
          })
        }
        that.setData({
          case:res.data.Result.Items
        })
      }

    })
  },
  onPageScroll: function(e){
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.case()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  }
})